﻿#include "mainwindow.h"
#include "ui_mainwindow.h"


MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    //connect(ui->pushButton,&QPushButton::clicked,this,&MainWindow::on_pushButton_clicked);
}

MainWindow::~MainWindow()
{
    delete ui;
}

void MainWindow::paintEvent(QPaintEvent *event)
{
    QPainter Mypaint(this);//创建画家
    //Mypaint.drawLine(0,100,1000,100);
    //生成一个圆心坐标为（100，100），半径为100的圆
    if(shouldcircle)
    {
        Mypaint.drawEllipse(0,0,200,200);//内接圆的矩形的左上角坐标，然后是矩形的长和宽
    }
}


void MainWindow::on_pushButton_clicked()
{//代码槽slot，写触发事件的代码的地方
    ui->pushButton->setText("成功了");
    shouldcircle=true;
    update();//repaint()也可以
}


void MainWindow::on_pushButton_3_clicked()
{
    shouldcircle=false;
    update();
}


void MainWindow::on_pushButton_2_clicked()
{
   clickNumber++;
   QString str=QString("点击量:%1").arg(clickNumber);
   ui->pushButton_2->setText(str);
}
